<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;


/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

Route::group( ['prefix' => '/v1' ], function (){
    Route::post('/login', "User\LoginController@login");
    //员工路由
    Route::middleware(['login'])->group(function (){
        Route::get('/event/my',"User\EventController@getEvent");
        Route::get('/event/{event_id}',"User\EventController@getIdEvent");
        Route::post('/logout', 'User\LoginController@logout');
        Route::get('/datetime', 'User\LoginController@getCurrentTime');
        Route::post('/employee/accept/{event_id}', 'User\EmployeesController@acceptEvent');
        Route::post('/employee/finish/{event_id}', 'User\EmployeesController@finishEvent');

        //管理员路由
        Route::middleware(['type_auth:0'])->group(function (){
            Route::get('/event',"Admin\EventController@getEvent");
            Route::post('/event',"Admin\EventController@createEvent");
            Route::patch('/event/employees/{event_id}',"Admin\EventController@updateEmployees");
            Route::patch('/event/client/{event_id}',"Admin\EventController@updateClient");
            Route::delete('/event/{event_id}',"Admin\EventController@deleteEvent");

            //员工
            Route::group([], function (){
                Route::get('/employee',"Admin\EmployeesController@getEmployeesList");
                Route::get('/employee/{employee_id}',"Admin\EmployeesController@getEmployeesInfo");
                Route::delete('/employee/{employee_id}',"Admin\EmployeesController@deleteEmployees");
                Route::post('/employee',"Admin\EmployeesController@addEmployee");
            });

            //客户
            Route::group([], function (){
                Route::get('/client',"Admin\ClientController@getClientList");
                Route::get('/client/{client_id}',"Admin\ClientController@getClientInfo");
                Route::delete('/client/{client_id}',"Admin\ClientController@deleteClient");
                Route::post('/client',"Admin\ClientController@addClient");
            });

        });

    });

    //游客路由
    Route::group([], function (){
        Route::get('/event-list', 'Tourist\EventController@getTouristEventList');
        Route::get('/event/preview/{event_code}', 'Tourist\EventController@getTouristEvent');
        Route::get('/history-list', 'Tourist\EventController@getTouristHistorySearch');
        Route::get('/event/detail/{event_code}/{client_phone}', 'Tourist\EventController@getTouristEventDetail');
        Route::post('/event/check/{event_id}/{event_code}', 'Tourist\EventController@touristCheckCode');
        Route::post('/enroll/{event_id}', 'Tourist\EventController@touristRegister');
        Route::get('/enroll/{email}/{phone}', 'Tourist\EventController@getTouristEventRegister');
    });
});

